#include <cmath>
#include<iostream>
using namespace std;
class Solution {
public:
    bool judgeSquareSum(int c) {
        int a=0;
        long b=sqrt(c);
        while(a<=b)
        {   
            while(a*a+b*b-c>0)b--;
            while(a*a+b*b-c<0)a++;
            if(a<=b&&a*a+b*b-c==0)return true;
        }
        return false;
    }
};